package com.ideaaedi.logback.defender.plugin;

import ch.qos.logback.classic.spi.ILoggingEvent;
import com.ideaaedi.logback.defender.defender.LogbackMessageDefender;
import org.springframework.stereotype.Component;

/**
 * (non-javadoc)
 *
 * @author JustryDeng
 * @since 2021/7/25 12:28:26
 */
@Component
public class PluginOne implements LogbackMessageDefender {
    
    public static final String HANDLE_BY_PLUGIN = "PluginOneAbc";
    
    @Override
    public boolean support(ILoggingEvent event) {
        return event.getMDCPropertyMap().containsKey(HANDLE_BY_PLUGIN);
    }
    
    @Override
    public void desensitize(ILoggingEvent event, String message, StringBuilder buffer) {
        buffer.append("[O_O] ").append(event.getFormattedMessage()).append(" [O_O]");
    }
}
